Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

senpai: use SCFG format #4086

Closed
wants to merge 11 commits into from
Closed

senpai: use SCFG format #4086

wants to merge 11 commits into from

Conversation

jleightcap
Copy link

@jleightcap jleightcap commented Jun 13, 2023

Description

Closes #2534.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

xdg.configFile."senpai/senpai.yaml".source =
cfgFmt.generate "senpai.yaml" cfg.config;
xdg.configFile."senpai/senpai.scfg".text = let
toSCFG' = v:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an inline generator for the (pretty custom) SCFG format. Would a PR to add this to generators.nix be more appropriate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in this PR.

Fix NixOS/nixpkgs#148667 introducing the
backwards-incompatible change of using the SCFG format
(https://git.sr.ht/~emersion/scfg).

Signed-off-by: Jack Leightcap <jack@leightcap.com>
@jleightcap jleightcap marked this pull request as ready for review June 13, 2023 07:54
@ncfavier
Copy link
Member

I'd really rather keep the freeformType and add an SCFG generator. I wonder to what extent our toKDL generator produces valid SCFG.

@ncfavier
Copy link
Member

The renamed options can have mkRenamedOptionModules for a smooth transition.

remove @malte-v: #4086 (comment)
add jleightcap (commit author)

Signed-off-by: Jack Leightcap <jack@leightcap.com>
nicknames 16
}

password-cmd gopass show irc/guest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be password-cmd "gopass show irc/guest"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@ncfavier ncfavier Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but password-cmd is intentionally parsed as a list of arguments to be fed to an execve-like interface, rather than a single shell command string: https://git.sr.ht/~taiite/senpai/tree/master/item/config.go#L199-214

The option should reflect that by having type nullOr (listOf str). This will avoid giving users the illusion that they can use shell syntax and quoting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand. Thank you for the well reasoned response -- an option wrapping execve as a list of strings is much more correct 🙂

@ncfavier
Copy link
Member

As far as I can tell, toKDL works fine at least for the test configuration. We just need to filter out null values.

Maybe just add toSCFG = toKDL; in generators.nix for now?

Signed-off-by: Jack Leightcap <jack@leightcap.com>
Signed-off-by: Jack Leightcap <jack@leightcap.com>
two prior config choices:

- `addr`
- `nick`

are renamed to match expected keys from upstream.

Signed-off-by: Jack Leightcap <jack@leightcap.com>
removed upstream. move into `extraConfig` with `tls` option.

Signed-off-by: Jack Leightcap <jack@leightcap.com>
@jleightcap
Copy link
Author

As far as I can tell, toKDL works fine at least for the test configuration. We just need to filter out null values.

Maybe just add toSCFG = toKDL; in generators.nix for now?

Unfortunately existing toKDL isn't close enough to SCFG, mostly related to string handling, but thanks for the pointer. Instead I've included a de novo generator here.

Let me know if more testing is warranted -- since senpai seems to be the only package in-tree that supports SCFG I didn't aim for a fully general generator.

Signed-off-by: Jack Leightcap <jack@leightcap.com>
Signed-off-by: Jack Leightcap <jack@leightcap.com>
modules/programs/senpai.nix Show resolved Hide resolved
modules/programs/senpai.nix Outdated Show resolved Hide resolved
modules/programs/senpai.nix Show resolved Hide resolved
modules/lib/generators.nix Outdated Show resolved Hide resolved
modules/programs/senpai.nix Outdated Show resolved Hide resolved
Signed-off-by: jleightcap <jack@leightcap.com>
Comment on lines +7 to +23
imports = [
(mkRenamedOptionModule [ "programs" "senpai" "addr" ] [
"programs"
"senpai"
"address"
])
(mkRenamedOptionModule [ "programs" "senpai" "nick" ] [
"programs"
"senpai"
"nickname"
])
(mkChangedOptionModule [ "programs" "senpai" "no-tls" ] [
"programs"
"senpai"
"tls"
] (config: !config.programs.senpai.no-tls))
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly this is not going to work because of NixOS/nixpkgs#96006. (Well, and also because this is defined in a let in but not used)

I think the best we can do for now is add assertions that the old options aren't used...

Sorry for leading you to a wrong track, this corner of the module system isn't quite ready yet.

@stale
Copy link

stale bot commented Sep 21, 2023

Thank you for your contribution! I marked this pull request as stale due to inactivity. Please read the relevant sections below before commenting.

If you are the original author of the PR

  • GitHub sometimes doesn't notify people who commented / reviewed a PR previously when you (force) push commits. If you have addressed the reviews you can officially ask for a review from those who commented to you or anyone else.
  • If it is unfinished but you plan to finish it, please mark it as a draft.
  • If you don't expect to work on it any time soon, please consider closing it with a short comment encouraging someone else to pick up your work.
  • To get things rolling again, rebase the PR against the target branch and address valid comments.

If you are not the original author of the PR

  • If you want to pick up the work on this PR, please create a new PR and indicate that it supercedes and closes this PR.

@stale stale bot added the status: stale label Sep 21, 2023
@patwid patwid mentioned this pull request Nov 12, 2023
5 tasks
@jleightcap jleightcap closed this by deleting the head repository Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: senpai new config format
3 participants